//
//  Factory.m
//  BaseProject
//
//  Created by yang_0921 on 15/11/12.
//  Copyright © 2015年 Tarena. All rights reserved.
//

#import "Factory.h"

@implementation Factory

/**
 *  添加返回按钮到控制器的导航栏上
 */
+ (void)addBackItemToVC:(UIViewController *)vc{
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundImage:[UIImage imageNamed:@"top_navigation_back"] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"top_navigation_back"] forState:UIControlStateHighlighted];
    btn.frame = CGRectMake(0, 0, 40, 40);
    [btn bk_addEventHandler:^(id sender) {
        [vc.navigationController popViewControllerAnimated:YES];
    } forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *menuItem=[[UIBarButtonItem alloc] initWithCustomView:btn];
    //使用弹簧控件缩小菜单按钮和边缘距离
    UIBarButtonItem *spaceItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    spaceItem.width = -10;
    vc.navigationItem.leftBarButtonItems = @[spaceItem,menuItem];
}


+ (void)addTitleInVC:(UIViewController *)vc{
    
    UIImageView *titleImages = [[UIImageView alloc] init];
    titleImages.image = [UIImage imageNamed:@"navbar_netease"];
    titleImages.frame = CGRectMake(0, 0, 60, 30);
    vc.navigationItem.titleView = titleImages;
    
}



@end
